class Solution:
    def coinChange(self, coins: List[int], amount: int) -> int:
        def dp(amount):
            if amount==0:
                return 0
            if amount<0:
                return -1
            mini=int(1e9)
            for i in self.coins:
                temp=dp(amount-i)
                if temp>=0 and temp<mini:
                    mini=temp+1
            return mini if mini<int(1e9) else -1
        self.coins=coins
        return dp(amount)